﻿$(function () {
    $.ModelDialog({
        title: "网站设置", width: 450,
        href: "tour/website/Edit.aspx",
        handler: function () {
            $.ModelForm({
                validate: true, button: $(this),
                editor: "#website-copyright",
                id: "#website-model",
                url: $.Api("Sys/Setting/Website"),
                success: function (result) { }
            });
        },
        onLoad: function () {
            $.MiniEditorInit("#website-copyright", 100, "p", false);
        }
    });
});

var Website = {
    //显示封面
    ImgShow: function () {
        text = "查看封面"; file = $("#website-videofront").val();

        var img = "<img style='display:block; margin:auto;' src='../userfiles/website/" + file + "' />";
        var box = "<div style='width:" + 218 + "px;height:" + 140 + "px;'>" + img + "</div>";

        $.ModelDialog({ title: text, width: 232, iconCls: "icon-images", content: box });
    },
    //上传封面
    ImgAdd: function () {
        KindEditor.editor({
            uploadJson: $.Api("Sys/Setting/ImgVideo"), formatUploadUrl: false
        }).loadPlugin("image", function () {
            this.plugin.imageDialog({
                showRemote: false, clickFn: function (url, title, width, height, border, align) {
                    $.EasyuiSlide("上传成功!"); this.hideDialog(); $("#website-videofront").val(url);
                }
            });
        });
    },
    //清除封面
    ImgDelete: function () {
        $("#website-videofront").val("null.png"); $.EasyuiSlide("清除成功!");
    },

    //显示视频
    FlvShow: function () {
        text = "查看封面"; file = $("#website-videoflv").val();

        var flv = "../userfiles/website/" + file;

        var embed = '<embed src="../public/jwplayer.swf"' +
        'id="jwplayer" name="jwplayer" width="480" height="320"' +
        'type="application/x-shockwave-flash" allowfullscreen="true"' +
        'pluginspage="http://www.macromedia.com/go/getflashplayer"' +
        'flashvars="&controlbar=none&file=' + flv + '" />'
        var box = "<div style='width:" + 480 + "px;height:" + 323 + "px;'>" + embed + "</div>";

        $.ModelDialog({ title: text, width: 494, iconCls: "icon-film", content: box });
    },
    //上传视频
    FlvAdd: function () {
        KindEditor.editor({
            uploadJson: $.Api("Sys/Setting/FlvVideo"), formatUploadUrl: false
        }).loadPlugin("insertfile", function () {
            this.plugin.fileDialog({
                showRemote: false, clickFn: function (url, title) {
                    $.EasyuiSlide("上传成功!"); this.hideDialog(); $("#website-videoflv").val(url);
                }
            });
        });
    },
    //清除视频
    FlvDelete: function () {
        $("#website-videoflv").val("null.mp4"); $.EasyuiSlide("清除成功!");
    }
};